package net.viralpatel.spring3.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloWorldController {
	
	@RequestMapping("/hello") // @RequestMapping({"/","/home"})
	public ModelAndView helloWorld(){
		String message = "Hello World, Spring 3.0!";
        return new ModelAndView("hello", "message", message);
	}
	
	@RequestMapping("/addCategories") 
	public ModelAndView addCategories(){		
        return new ModelAndView("addCategories", "", "");
	}
	
	@RequestMapping("/addLocation") 
	public ModelAndView addLocation(){		
        return new ModelAndView("addLocation", "", "");
	}
	
	@RequestMapping("/addItems") 
	public ModelAndView addItems(){		
        return new ModelAndView("addItems", "", "");
	}
	
	
	@RequestMapping(value = "/hi", method = RequestMethod.POST)
	  public String hi(@RequestParam("name") String name, Model model) {
	    String message = "Hi " + name + "!";	
	    model.addAttribute("message", message);
	    return "hi";
	  }

}
